import GPS from '../tools/gps/gps.js'
import store from '../vuex/'
//import router from '../router/'

var MyPlugin = {};
MyPlugin.install = function(Vue) {
	let myCommon = {
		userInfo: {},
		//通过摄像头拍照或者录像
		showLoading: function() {
			store.commit('updateLoadingStatus', {
				isLoading: true
			})
		},
		hidenLoading: function() {
			store.commit('updateLoadingStatus', {
				isLoading: false
			})
		},
		//路由跳转
		routerGo: function(name, params) {
			Vue.router.push({
				name: name,
				params: params
			})
		},
		//路由替换
		routerReplace: function(name, params) {
			Vue.router.replace({
				name: name,
				params: params
			})
		},
		showToast(msg) {
			store.commit('updateToast', {
				show: true,
				text: msg
			})
		},
		getNowDate() {
			var date = new Date();
			var month = date.getMonth() + 1;
			if(month < 10)
				month = "0" + month;
			var strDate = date.getDate();
			if(strDate < 10)
				strDate = "0" + strDate;
			var currentdate = date.getFullYear() + "-" + month + "-" + strDate;
			return currentdate;
		}
	}
	Vue.prototype.$common = myCommon;
	//	Vue.native = myNative;
};

export default MyPlugin;